﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;
using HRM.DAL.Report;

namespace HRM.BLL
{
    public class TrainingManager
    {
        TrainingGateway gateway = new TrainingGateway();
        public bool SaveTraining(Training training)
        {
            return gateway.SaveTraining(training);
        }
        public bool UpdateTrainingInfo(int Id, Training training)
        {

            return gateway.UpdateTrainingInfo(Id, training);
        }
        public Training GetTraining(int id)
        {
            return gateway.GetTraining(id);
        }

        public List<Training> GetAllTrainings()
        {
            return gateway.GetAllTrainings();
        }
        public bool DeleteTraing(int id)
        {
            return gateway.DeleteTraing(id);
        }

        public bool AssignEmployeeToTraining(TrainedEmployee trainee)
        {
            EmployeeManager employeeManager = new EmployeeManager();
            int empId = employeeManager.GetEmployeeID(trainee.Employee.EmpCode);
            if (gateway.IsTraineeAlreadyAssigned(empId, trainee))
            {
                return false;
            }
            else
            {
                return gateway.AssignEmployeeToTraining(empId, trainee);
            }
        }

        public List<ReportTrainedEmployee> GetAllTrainedEmployee(int trainingId)
        {
            return gateway.GetAllTrainedEmployee(trainingId);
        } 
    }
}